class Exploitdb < Formula
  desc "Database of public exploits and corresponding vulnerable software"
  homepage "https://www.exploit-db.com/"
  url "https://gitlab.com/exploit-database/exploitdb.git",
      tag:      "2024-02-03",
      revision: "81ae91fdae912a30b4448d35434d4ebfd4ac5b1a"
  license "GPL-2.0-or-later"
  head "https://gitlab.com/exploit-database/exploitdb.git", branch: "main"

  bottle do
    sha256 cellar: :any_skip_relocation, arm64_sonoma:   "1e48e32eda995892e49541fa1f6be0478e6009fbe930e46a3bfdbd2c38cbd078"
    sha256 cellar: :any_skip_relocation, arm64_ventura:  "1101388ba7b4841786c8b28a20039bac66361d184cb3ffcf004059c7c509c461"
    sha256 cellar: :any_skip_relocation, arm64_monterey: "342543fdf36443ad9f51a3316daf1e2fa8ee4f80d840b8488577d50d7dda1751"
    sha256 cellar: :any_skip_relocation, sonoma:         "2cc547463e31a149416fdaa9a88089f29fd1f74f1610e222563cbf4264931d2d"
    sha256 cellar: :any_skip_relocation, ventura:        "69b5703667a1de5fe24bd484e5bbbf16c5bcfa276cb1e57d96b4a8aa013069b2"
    sha256 cellar: :any_skip_relocation, monterey:       "8af9c6195a65f36db115a827e9795dc9b9178240ac638d3cb346eb972363f1cf"
    sha256 cellar: :any_skip_relocation, x86_64_linux:   "ba9ecf7a92e9a1270e3fc30b75a466ec04bf5af5406f2d5382064d4a269c5a29"
  end

  def install
    inreplace "searchsploit",
              "rc_file=\"\"", "rc_file=\"#{etc}/searchsploit_rc\""

    optpath = opt_share/"exploitdb"
    inreplace ".searchsploit_rc" do |s|
      s.gsub! "\"/opt/exploitdb\"", optpath
      s.gsub! "\"/opt/exploitdb-papers\"", "#{optpath}-papers"
    end

    bin.install "searchsploit"
    etc.install ".searchsploit_rc" => "searchsploit_rc"

    pkgshare.install %w[.git exploits files_exploits.csv files_shellcodes.csv
                        shellcodes]
  end

  test do
    system "#{bin}/searchsploit", "sendpage"
  end
end
